<template>
  <ElDialog v-bind="$attrs">
    <ElForm label-width="auto" style="width: 300px">
      <ElFormItem label="编号">
        <ElTag>{{ leaveAction.leaveId }}</ElTag>
      </ElFormItem>
      <ElFormItem label="申请人">
        <ElTag>{{ leaveAction.applier }}</ElTag>
      </ElFormItem>
      <ElFormItem label="审核人">
        <ElSelect v-model="leaveAction.auditor">
          <ElOption :label="'王五'" :value="'wangwu005'"></ElOption>
          <ElOption :label="'赵六'" :value="'zhaoliu006'"></ElOption>
        </ElSelect>
      </ElFormItem>
      <ElFormItem label="请假原因">
        <ElTag>{{ leaveAction.reason }}</ElTag>
      </ElFormItem>
      <ElFormItem>
        <ElButton @click="submit" type="success">提交</ElButton>
      </ElFormItem>
    </ElForm>
    <!-- <div>{{ leaveAction }}</div> -->
  </ElDialog>
</template>
<script lang="ts">
import axios from "@/api/axiosConfig";
import { flattedChildren } from "element-plus/es/utils";
import { defineComponent } from "vue";

/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import from
// properties  prop
// attributes  attr

export default defineComponent({
  name: "LeaveSubmit",
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
    contentId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      sampleD: "value",
      leaveAction: {
        leaveId: "",
        actionState: "",
        leaveType: "",
        startTime: null,
        endTime: null,
        reason: "",
        pic: "",
        applier: "",
        applierTime: null,
        auditor: undefined,
        auditMsg: null,
        updateTime: null,
      },
    };
  },
  computed: {
    /* sampleC() {
      return this.sampleD + "--";
    }, */
  },
  created() {},
  mounted() {},
  methods: {
    // sampleM() {},
    async submit() {
      const d = {
        leaveId: "",
        auditor: undefined,
      };
      d.leaveId = this.leaveAction.leaveId;
      d.auditor = this.leaveAction.auditor;
      const res = await axios({
        method: "put",
        url: "/leaveAction/submit",
        data: d,
      });
      // 优化用户体验
      // father.go(1)
      this.$emit("after-submit",1)
    },
  },
  watch: {
    // sampleP(n, o) {},
    async contentId(n, o) {
      // console.log("axios发送请求查询"+n)
      if (!n) return;
      const res = await axios({
        method: "get",
        url: "/leaveAction/findById/" + this.contentId,
      });
      this.leaveAction = res.data;
 
      
    },
  },
});
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
